package Bank;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 交易记录类
 * 用于存储每个银行账户的交易信息
 *@date	2014.8.17
 */
public class Transaction {
	private Date time=null;
	private String type=null;
	private double amount =0;
	static private int count =0;
	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

	public Transaction(Date time, String type, double amount) {
		this.time = time;
		this.type = type;
		this.amount = amount;
		count++;
	}
	
	static int getCount(){
		return count;
	}
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
		count++;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public double getAmount() {
		return amount;
	}
	public void setAmount(double amount) {
		this.amount = amount;
	}
	
	/**
	 * 打印交易信息
	 */
	public void show(){
		System.out.println("date: "+sdf.format(this.getTime())+" type: "+this.getType()+ " amount: "+this.getAmount());
	}
	
}
